package md.lanjing.com.module_deal_center.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import md.lanjing.com.module_deal_center.api.DealApiService;
import md.lanjing.com.module_deal_center.bean.BuyOrderStateRequest;
import md.lanjing.com.module_deal_center.bean.BuyOrderStateResponce;
import com.lxh.baselibray.constant.Constant;
import retrofit2.Call;
import retrofit2.Response;

public class BuyOrderStateContact {
    public static class BuyOrderStatePresent extends BasePresent<IBuyOrderStateView> {
        public void buyOrderState(final Context context, int type, int pageNo){
            DealApiService service= ServiceGenerator.createService(DealApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            BuyOrderStateRequest request=new BuyOrderStateRequest(userId,type,pageNo);
            service.queryBuyStateOrder(request).enqueue(new NetCallBack<BuyOrderStateResponce>() {
                @Override
                public void onSuccess(Call<BuyOrderStateResponce> call, Response<BuyOrderStateResponce> response) {
                    if (getView()!=null){
                        getView().getBuyOrderStateData( response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IBuyOrderStateView extends IBaseView {
        void getBuyOrderStateData(Response<BuyOrderStateResponce> response);
    }
}
